<template>
	<view class="pb-safe-area">
		<view class="p-4">
			<mp-html :content="content" selectable class="text-wrap content"></mp-html>
		</view>
	</view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { $http, $page } from '@/utils';
import { onLoad } from '@dcloudio/uni-app';
import { $ResponseCode } from '@/utils/const/env';
const content = ref('');

onLoad((options: any) => {
	let url = 'Article/getContent';
	if (options.alias) {
		url = 'Article/getContentByAlias';
	}
	$http.get(url, {
		data: {
			id: options.id,
			alias: options.alias
		}
	}).then((res: any) => {
		if (res.code === $ResponseCode.SUCCESS) {
			$page.title(res.data.title);
			content.value = res.data.content;
		} else {
			uni.showModal({
				title: '提示',
				content: res.msg,
				showCancel: false,
				success: () => {
					$page.back();
				}
			})
		}
	})
})
</script>
